package it.unibo.iss.contact.domoticaContact;

import it.unibo.contact.platform.InteractPolicy;
import it.unibo.contact.platform.PlatformExpert;
import it.unibo.is.interfaces.*;
import it.unibo.is.interfaces.platforms.*;
import java.util.Vector;
	

public abstract class  UsrcmdContactSupport extends Subject{
	/* -------------------------------------
	* Local state of the subject
	* --------------------------------------
	*/
	
	protected String M = "someContent";	
	protected int lastMsgNum = 0; 
	private UsrcmdContact obj = null; //The user must define UsrcmdContact
//	private  IOutputView view;
	protected Vector<IMessage> inpList;
	
	/* -------------------------------------
	* OPERATIONS
	* --------------------------------------
	*/
	
	
	
	protected IAcquireOneReply usrcmdContactDemand_listEd_edController() throws Exception{
		
	IOpOut support = PlatformExpert.findOutSupport("edController","listEd","usrcmdContact");
	IAcquireOneReply answer = 
		support.demand( "usrcmdContact", "listEd", M, "edController", InteractPolicy.nopolicy() );
//	showMsg(  "has demanded ... " + "listEd to " + " edController" );
	return answer;
	}
	
	protected IAcquireOneReply usrcmdContactDemand_powerOn_edController() throws Exception{
		
	IOpOut support = PlatformExpert.findOutSupport("edController","powerOn","usrcmdContact");
	IAcquireOneReply answer = 
		support.demand( "usrcmdContact", "powerOn", M, "edController", InteractPolicy.nopolicy() );
//	showMsg(  "has demanded ... " + "powerOn to " + " edController" );
	return answer;
	}
	
	protected IAcquireOneReply usrcmdContactDemand_powerOff_edController() throws Exception{
		
	IOpOut support = PlatformExpert.findOutSupport("edController","powerOff","usrcmdContact");
	IAcquireOneReply answer = 
		support.demand( "usrcmdContact", "powerOff", M, "edController", InteractPolicy.nopolicy() );
//	showMsg(  "has demanded ... " + "powerOff to " + " edController" );
	return answer;
	}
	
	protected void usrcmdContactForward_abortPowerOn_edController() throws Exception{
		IOpOut support = PlatformExpert.findOutSupport("edController","abortPowerOn","usrcmdContact");
		support.forward( "usrcmdContact", "abortPowerOn" , M, "edController", InteractPolicy.nopolicy() );
//		showMsg( " has forwarded ... " + "abortPowerOn  to " + " edController" );
	}
	
	protected IMessage usrcmdContactServe_listEdSuperflui() throws Exception{
		IOpIn support = PlatformExpert.findInSupport("usrcmdContact","listEdSuperflui",false );
		IMessage m =  support.serve( "usrcmdContact", "listEdSuperflui", InteractPolicy.nopolicy()  ); 
		//showMessage( "serving" , m );
		return m;
	}
		
	/* -------------------------------------
	* Local body of the subject
	* --------------------------------------
	*/
 
	protected abstract void doJob() throws Exception;	/*{
	[it.unibo.is.contact.impl.serveDispatchImpl@38fff7]
	[]
 	 //	INPUT
   	prepareInput();
   	IMessage mm = selectOneInput(lastMsgNum, inpList);
   	elab(mm.msgId());
	//	OUTPUT
	{	
	IAcquireOneReply m = usrcmdContactDemand_listEd_edController() ;
	evalResponse_listEd_edController( m );
	
	}
	{	
	IAcquireOneReply m = usrcmdContactDemand_powerOn_edController() ;
	evalResponse_powerOn_edController( m );
	
	}
	{	
	IAcquireOneReply m = usrcmdContactDemand_powerOff_edController() ;
	evalResponse_powerOff_edController( m );
	
	}
	{	 usrcmdContactForward_abortPowerOn_edController() ;
	}
 	}  */	

	


	

	
	/* -------------------------------------
	* Termination
	* --------------------------------------
	*/
	
protected void terminate() throws Exception{
	usrcmdContactDemand_listEd_edControllerEnd();
	usrcmdContactDemand_powerOn_edControllerEnd();
	usrcmdContactDemand_powerOff_edControllerEnd();
	usrcmdContactForward_abortPowerOn_edControllerEnd();

	usrcmdContactServe_listEdSuperfluiEnd();
	
//showMsg("  *** TERMINATED *** ");
}
//Teminate operations

	 
	protected void usrcmdContactDemand_listEd_edControllerEnd() throws Exception{
		
		IOpOut support = PlatformExpert.findOutSupport("edController","listEd","usrcmdContact");	 
		support.terminate();
		}
	 
	protected void usrcmdContactDemand_powerOn_edControllerEnd() throws Exception{
		
		IOpOut support = PlatformExpert.findOutSupport("edController","powerOn","usrcmdContact");	 
		support.terminate();
		}
	 
	protected void usrcmdContactDemand_powerOff_edControllerEnd() throws Exception{
		
		IOpOut support = PlatformExpert.findOutSupport("edController","powerOff","usrcmdContact");	 
		support.terminate();
		}
	
	protected void usrcmdContactForward_abortPowerOn_edControllerEnd() throws Exception{
		IOpOut support = PlatformExpert.findOutSupport("edController","abortPowerOn","usrcmdContact");
		support.terminate();
	}
	
	
	protected void usrcmdContactServe_listEdSuperfluiEnd() throws Exception{
		IOpIn support = PlatformExpert.findInSupport("usrcmdContact","listEdSuperflui",false );
		support.terminate();
	}
	

}
